package com.chagee.store.operation.server.service.biz;

import com.chagee.base.utils.PaginationRequest;
import com.chagee.store.operation.server.service.third.StoreThirdService;
import com.chagee.storeManagement.api.event.request.OperateRecordRequest;
import com.chagee.storeManagement.api.event.request.QueryOperateRecordInfoRequest;
import com.chagee.storeManagement.api.event.response.BasePageResponse;
import com.chagee.storeManagement.api.event.response.QueryStoreOperateRecordResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 操作记录
 * @Author : hk
 * @Date : 2025/3/19
 */

@Slf4j
@Service
@RequiredArgsConstructor
public class OperateRecordBizService {

	@Resource
	private StoreThirdService storeThirdService;

	// 操作日志
	public static final Integer APPEAL_TYPE = 11;


	// 操作类型
	public static final String INSERT_OPERATE_TYPE = "insert";
	public static final String UPDATE_OPERATE_TYPE = "update";
	public static final String DELETE_OPERATE_TYPE = "delete";

	/**
	 * 新增类型操作记录
	 */
	public void addOptRecord(OperateRecordRequest request) {
		request.setOperateType(INSERT_OPERATE_TYPE);
		request.setRecordType(APPEAL_TYPE);
		storeThirdService.addOperateRecord(request);
	}

	/**
	 * 修改类型操作记录
	 */
	public void updateOptRecord(OperateRecordRequest request) {
		request.setOperateType(UPDATE_OPERATE_TYPE);
		request.setRecordType(APPEAL_TYPE);
		try {
			storeThirdService.addOperateRecord(request);
		} catch (Exception e) {
			log.info("添加修改类型操作记录失败:", e);
		}
	}

	public BasePageResponse<QueryStoreOperateRecordResponse> queryRecordPage(PaginationRequest<QueryOperateRecordInfoRequest> request) {
		BasePageResponse<QueryStoreOperateRecordResponse> response = storeThirdService.queryRecordByStoreNoAndRecordType(request);
		return response;
	}
}
